<template>
  <div class="home">
    这是首页
  </div>
</template>

<script>
export default {
  
  data() {
    return {
      name: "mm",
      pass: "8888",
      okToken:null
    };
  },
  beforeCreate: function() { 

      //console.log("创建前")            
      //window.location.href = "https://www.baidu.com"      

  },
  created:function(){
    
  },
  mounted:function(){
    //router.push('https://www.baidu.com');  
  },
  components: {},

  methods: {
    login: function() {
      const _this = this
      
      this.$axios
        .post("./api/login", {
          name: this.name,
          pass: this.pass
        })
        .then(function(response) {
          console.log("拿到token")
          if(response.data.code="200"){
              utils.setCookie("token",response.data.result.token,5)
              utils.setCookie("tickname",response.data.result.username,21600)
          }else{
            Message.error(response.data.message);
          }
          //console.log(response.data)
          //console.log(response.data.result.token)
        })
          
    },
    setToken:function(){
      console.log(this.okToken);
      this.$axios.get("/api/setToken", {
                    params: {
                        'token': this.okToken,
                        
                    }
                }).then(function(response) {

                }).catch(function(error) {
                  console.log(error);
                });
    },
    testU:function(){
      this.$axios.get("/api/checkToken", {
                    params: {
                        'token': localStorage.token,
                        
                    }
                }).then(function(response) {
console.log(response)
                }).catch(function(error) {
                  console.log(error);
                });
    },
    //每次请求 验证token
    toTken:function(){
      this.$axios.get("/jwt/checkToken", {
                    params: {
                        'token': 'ioioioio999',
                        
                    }
                }).then(function(response) {
console.log(response)
                }).catch(function(error) {
                  console.log(error);
                });
    }
    
  }
};
</script>
